﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FSWS.Commonality
{
    /// <summary>
    /// 读取文本文件
    /// </summary>
    public static class ReadTxt
    {
        /// <summary>
        /// 将文本文件中的每一行都作为一个元素添加到字符串集合中
        /// </summary>
        /// <param name="path">文本路径</param>
        /// <returns>包含敏感词的字符串集合</returns>
        public static List<string> GetListForTxt(string path)
        {
            List<string> listStr = new List<string>();
            try
            {
                if (File.Exists(path))
                {
                    StreamReader sr = new StreamReader(path, Encoding.Default);
                    string line;
                    while ((line = sr.ReadLine()) != null)
                    {
                        listStr.Add(line);
                    }
                }
            }
            catch
            {

            }
            return listStr;
        }
    }
}
